/*Nn3v3QQQ2KVXFyw+qmWIHnVtrK7sM8B+4REIHFV/ByPfERVTh1S0aRxT9JYc3fhS*/
/*
 * @Author: xiahui 
 * @PageInfo: 付款执行情况
 * @Date: 2019-02-26 15:38:07 
 * @Last Modified by: yinliangc
 * @Last Modified time: 2022-07-22 11:02:17
 */
import { AREA, URL, FIELDS } from '../../constance';
import { viewModel } from 'nc-lightapp-front';
let { setGlobalStorage } = viewModel;

export default function(props) {
	let checkedRows = props.table.getCheckedRows(AREA.listTableId);

	let arrstr = [];
	let str = '';
	let vbillcode = '';
	checkedRows.map((item) => {
		if (item.data.values.pk_org.value) {
			arrstr.push(item.data.values.pk_org.value);
		}
		if (item.data.values.vbillcode.value) {
			vbillcode += item.data.values.vbillcode.value + ',';
		}
	});
	let strSet = [ ...new Set(arrstr) ];
	for (let i = 0; i < strSet.length; i++) {
		str += strSet[i] + ',';
	}
	let LinkReport = {
		logic: 'and',
		conditions: [
			{
				field: 'pk_org',
				value: {
					firstvalue: str,
					secondvalue: ''
				},
				oprtype: '=',
				display: null,
				isIncludeSub: false,
				refurl: '',
				datatype: '204'
			},
			{
				field: 'vbillcode',
				value: { firstvalue: vbillcode, secondvalue: '' },
				oprtype: '=',
				display: vbillcode,
				isIncludeSub: false,
				refurl: '',
				datatype: '1'
			}
		]
	};
	// localStorage.setItem('LinkReport', JSON.stringify(LinkReport));
	setGlobalStorage('localStorage', 'LinkReport', JSON.stringify(LinkReport));

	let params;
	if (checkedRows && checkedRows.length == 1) {
		// 只勾选一条数据
		params = {
			pk_org: checkedRows[0].data.values[FIELDS.pk_org],
			vbillcode: checkedRows[0].data.values[FIELDS.vbillcode],
			dmakedate: checkedRows[0].data.values[FIELDS.dmakedate].value
		};
	}
	// 跳转至采购合同付款执行情况查询报表
	props.openTo(null, {
		appcode: '400413242',
		pagecode: '400413242_report',
		params: JSON.stringify(params)
	});
}

/*Nn3v3QQQ2KVXFyw+qmWIHnVtrK7sM8B+4REIHFV/ByPfERVTh1S0aRxT9JYc3fhS*/